﻿namespace _13_集合;

internal class Program
{
    private static void Main(string[] args)
    {
        #region 1_ArrayList: 弱类型列表

        //// 在Collections中
        //ArrayList list = new ArrayList();
        //list.Add("张三");
        //list.Add(10);
        //list.Add("李四");
        //list.Add("王五");
        //list.Add("赵六");
        //list.Add("孙七");
        //list.Add("周八");
        //list.Add("吴九");
        //list.Add("郑十");
        //list.Add("王十一");
        //list.Add("李十二");
        //list.Add("孙十三");
        //list.Add("周十四");
        //list.Add("吴十五");
        //list.Add("郑十六");
        //list.Add("孙十七");
        //list.Add("周十八");
        //list.Add("吴十九");
        //list.Add("郑二十");
        //foreach (var item in list)
        //{
        //    Console.WriteLine(item);    
        //};

        #endregion

        #region 2_List: 强类型列表

        //List<string> list = new List<string>();
        //list.Add("张三");
        //list.Add("李四");
        //list.Add("王五");
        //list.Add("赵六");
        //list.Add("孙七");
        //list.Add("周八");
        //list.Add("吴九");
        //list.Remove("吴九");
        //list.Insert(2, "哈哈哈");
        //list.Add("郑十");
        //list.Add("王十一");
        //list.Add("李十二");
        //list.Add("孙十三");
        //list.Add("周十四");
        //list.Add("吴十五");
        //list.Sort();
        //foreach (var item in list)
        //{
        //    Console.WriteLine(item);
        //};

        #endregion

        #region 3_SortedList: 有序列表, 按照key排序

        //SortedList<int, string> list = new SortedList<int, string>();
        //list.Add(1, "张三");
        //list.Add(2, "李四");
        //list.Add(3, "王五");
        //list.Add(4, "赵六");
        //list.Add(5, "孙七");
        //list.Add(6, "周八");
        //list.Add(7, "吴九");
        //list.Add(8, "郑十");
        //list.Add(9, "王十一");
        //list.Add(10, "李十二");
        //list.Add(11, "孙十三");
        //foreach (var item in list)
        //{
        //    Console.WriteLine(item);
        //};

        #endregion

        #region 4_LinkedList

        //LinkedList<string> list = new LinkedList<string>();
        //list.AddFirst("张三");
        //list.AddLast("李四");
        //list.AddLast("赵六");
        //list.AddLast("孙七");

        //LinkedListNode<string> node = list.Find("赵六");
        //list.AddBefore(node, "王五");

        //foreach (var item in list)
        //{
        //    Console.WriteLine(item);
        //};

        #endregion

        #region 5_Dictionary:字典, 类似于Java中的Map

        //var domains = new Dictionary<string, string>();

        //domains.Add("de", "Germany");
        //domains.Add("sk", "Slovakia");
        //domains.Add("us", "United States");
        //domains.Add("ru", "Russia");
        //domains.Add("hu", "Hungary");
        //domains.Add("pl", "Poland");

        //Console.WriteLine(domains["sk"]);
        //Console.WriteLine(domains["de"]);

        //Console.WriteLine("Dictionary has {0} items",
        //    domains.Count);

        //Console.WriteLine("Keys of the dictionary:");

        //var keys = new List<string>(domains.Keys);

        //foreach (string key in keys)
        //{
        //    Console.WriteLine("{0}", key);
        //}

        //Console.WriteLine("Values of the dictionary:");

        //var vals = new List<string>(domains.Values);

        //foreach (string val in vals)
        //{
        //    Console.WriteLine("{0}", val);
        //}

        //Console.WriteLine("Keys and values of the dictionary:");

        //foreach (KeyValuePair<string, string> kvp in domains)
        //{
        //    Console.WriteLine("Key = {0}, Value = {1}",
        //        kvp.Key, kvp.Value);
        //}

        #endregion

        #region 6_Queue: 先进先出的数据结构

        //var queue = new Queue<string>();
        //queue.Enqueue("张三"); // 将信息添加到队列末尾
        //queue.Enqueue("李四");
        //queue.Enqueue("王五");
        //Console.WriteLine(queue.Dequeue()); // 弹出队列中的第一个元素, 与Peek不同的是, Dequeue会删除并返回该元素, 而Peek只会将该元素获取到
        //Console.WriteLine(queue.Peek()); // 获取队列中的第一个元素
        //Console.WriteLine(queue.Count());
        //Console.WriteLine();
        //foreach (var item in queue)
        //{
        //    Console.WriteLine(item);
        //}

        #endregion

        #region 7_Stack: 后进先出的数据结构: 方法啥的都和这个queue一样, 就是这个栈是先进后出, 而这个queue是先进先出

        //var stack = new Stack<string>();
        //stack.Push("张三"); // 将信息添加到栈顶
        //stack.Push("李四");
        //stack.Push("王五");
        //Console.WriteLine(stack.Pop()); // 弹出栈顶的元素
        //Console.WriteLine(stack.Peek()); // 获取栈顶的元素
        //Console.WriteLine(stack.Count());
        //Console.WriteLine();
        //foreach (var item in stack)
        //{
        //    Console.WriteLine(item);
        //}

        #endregion
    }
}